home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 July / macformat52.iso / mac / Shareware Plus / Educational / LEE 2.1 / Source / globals.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  5.3 KB  |  163 lines

  1. /* globals.c
  2.  *                         Copyright (1992)
  3.  *
  4.  *         Jeff Elman.  University of California, San Diego
  5.  *          Rik Belew.  University of California, San Diego
  6.  *      Stefano Nolfi.  Institute of Psychology, Rome.
  7.  *    Filippo Menczer.    University of California, San Diego
  8.  *        Greg Linden.    University of California, San Diego
  9.  *
  10.  *        This software may be redistributed without charge;
  11.  *                 this notice should be preserved.
  12.  */
  13.  
  14.  
  15.  
  16. #include "defs.h"
  17.  
  18. /*
  19.  * parameters
  20.  */
  21.  
  22.  
  23. #ifdef THINK_C
  24. WindowPtr        gTheWindow, gZoomCellWindow;
  25. DialogPtr        gInitDialog;
  26. MenuHandle        gAppleMenu, gFileMenu, gEditMenu, gOptionsMenu;
  27. boolean            gLassoOn = TRUE, gPaused = FALSE;
  28. Point            gCurrentZoomCell;
  29. int                gCurrentZoomItem=0;
  30. #endif
  31. #ifdef __MWERKS__
  32. WindowPtr        gTheWindow, gZoomCellWindow;
  33. DialogPtr        gInitDialog;
  34. MenuHandle        gAppleMenu, gFileMenu, gEditMenu, gOptionsMenu;
  35. boolean            gLassoOn = TRUE, gPaused = FALSE;
  36. Point            gCurrentZoomCell;
  37. int                gCurrentZoomItem=0;
  38. #endif
  39.  
  40.  
  41.  
  42. int x_dim; /* world x dimention (max=25 for Mac!) */
  43. int y_dim; /* world y dimention (max=25 for Mac!) */
  44. int types; /* number of atom (food) elements */
  45. int nsensors; /* total number of sensors, should be multiple of TYPES */
  46. int nmotors; /* total number of motors */
  47.  
  48. boolean            gDone = FALSE;
  49. boolean            gInteractive = FALSE;
  50.  
  51. boolean            saturation = FALSE;
  52.  
  53. unsigned long    seed;           /* random seed  */                      
  54. boolean        errsig = FALSE;     /* print error signal  */
  55. int    ecount = 0;            /* save global error every N sweeps         */
  56. int     learn = FALSE;         /* Turn on/off learning.  */
  57. boolean     printout = FALSE;    /*  print lifecycle information              */
  58. int     sweeps = INIT_LIFE_CYCLES;
  59.                 /*  Moves per organism per generation */
  60. float   rate = INIT_LEARN_RATE;
  61.                 /* Default learning rate */
  62. int     generations=INIT_GENERATIONS;
  63.                 /* number of generations                    */
  64. int     startgeneration = 0;  /* Generation to start with */
  65.  
  66. float   mutations_range = INIT_MUTATION_RANGE;
  67.                 /* range of mutations                       */
  68. int     mutations;         /* number weight mutations */
  69. int     bmutations;         /* number bias mutations       */
  70. boolean     mbiasestoo=TRUE;   /* if 1 we mutate biases too                */
  71. boolean     unary_reactions=FALSE;   /* if 1 we read unary reactions from .tu file        */
  72.  
  73. int     verbose=1;             /* verbose level  (0-1-2-3-4) */
  74. int     save_best=0;           /* save the best N individual each gen.     */
  75. int     save_everyn=0;         /* save individual each X generations       */
  76.  
  77.  
  78. /*
  79.  * files
  80.  */
  81.  
  82. FILE   *errfp;                   /* globals error file                       */
  83. FILE   *resfp;                 /* results file                             */
  84. char    fileroot[64] = FILE_ROOT;       /* for config file name */
  85.  
  86.  
  87. /*
  88.  * organisms
  89.  */
  90.  
  91. int     start_num_amoebas = INIT_POP;
  92.                 /* initial number of organisms        */
  93. int     gutsize;        /* initialized from .cf file */
  94. int    nlayers;        /* number of layers in network            */
  95. int    *layer_descp;        /* no. of nodes in each layer             */
  96. float    weight_limit=WEIGHT_LIMIT; /* for weight initialization */
  97.  
  98. struct  indiv    *a_head;    /* linked list of amoeba strux            */
  99. struct  indiv    *t_head;    /* linked list of amoeba strux            */
  100. struct  indiv    *end_head;    /* end of the chain                       */
  101.  
  102.  
  103. /*
  104.  * others
  105.  */
  106.  
  107. char    *optarg;        /* for options */
  108. float    global_error;        /* store global error                     */
  109. int     gen;                    /* current generation                     */
  110. int     lifecycle;              /* current lifecycle                      */
  111. float   amoebat[NINPUTS];            /*  amoeba teach array               */
  112. float   sigmoide[NSIGMA+1];     /*  logistic matrix                       */
  113. int    pop_size;        /* current number of organisms            */
  114. float energy_reserve=0.0;    /* energy at death accumulated
  115.                  * since start of run: <= 0.0 
  116.                  * (not saved if loading, -g)
  117.                  */
  118. int    s_type[MAXSENSORS];    /* sensor types */
  119. int    s_orient[MAXSENSORS];    /* sensor types */
  120. int    s_range[MAXSENSORS];    /* sensor types */
  121. int    m_type[MAXMOTORS];    /* motor types */
  122. offset  *off_vec[4][MAXRANGESIZE];    
  123.                 /* ambient sensor offsets 
  124.                  * with increasing range...
  125.                  * 1st index is direction:
  126.                  * 0 = LEFT, 1 = UP,
  127.                  * 2 = RIGHT, 3 = DOWN
  128.                  */
  129. float    norm_dist[MAXRANGE];    /* 
  130.                  * used for normalization of ambient 
  131.                  * sensor signal
  132.                  */
  133. reaction react_table[MAXTYPES][MAXTYPES];
  134.                 /* each entry of this
  135.                  * symmetric table has
  136.                  * the corresponding
  137.                  * reaction structure 
  138.                  */
  139. float    abundance = INIT_ABUNDANCE;
  140.                 /* Initial fraction of cells 
  141.                  * that may have each type of food;
  142.                  * for now, same for all types
  143.                  */
  144. cell *world[MAX_X][MAX_Y];     /* each cell points to a linked 
  145.                  * list of elements, one for each
  146.                  * food piece or (pointer to)
  147.                  * eventual individual present
  148.                  * in the cell
  149.                  */
  150. int    distrib[MAXTYPES][5];    /* the elements of each food
  151.                  * type have pseudo-normal
  152.                  * distribution, with these
  153.                  * 2-D centers and variances;
  154.                  * the latter is described in
  155.                  * terms of the number of
  156.                  * uniform distributions 
  157.                  * (i.e., calls to random())
  158.                  * we average over;
  159.                  * the last field gives the
  160.                  * regeneration rate for 
  161.                  * elements of that type
  162.                  */
  163.